package com.luisliuyi.demo.optimize.network;

import java.util.HashMap;
import java.util.Map;

public class Request {
    public static final String HEAD_HOST = "Host";
    public static final String HEAD_CONNECTION = "Connection";
    public static final String HEAD_VALUE_KEEP_ALIVE = "Keep-Alive";

    private String method = "GET";
    private HttpUrl httpUrl = null;
    public HttpUrl getHttpUrl() {
        return httpUrl;
    }

    public void setHttpUrl(HttpUrl httpUrl) {
        this.httpUrl = httpUrl;
        Map<String, String> tempHeaders = getHeaders();
        if (!tempHeaders.containsKey(HEAD_HOST)) {
            tempHeaders.put(HEAD_HOST,getHttpUrl().getHost());
        }
        if(!tempHeaders.containsKey(HEAD_CONNECTION)) {
            tempHeaders.put(HEAD_CONNECTION, HEAD_VALUE_KEEP_ALIVE);
        }
    }

    Map<String, String> headers = new HashMap<>();

    public String getMethod() {
        return method;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

}
